/*
 * sharedMemory.h
 *
 *  Created on: Mar 4, 2013
 *      Author: abrahamsantini
 */

#ifndef SHAREDMEMORY_H_
#define SHAREDMEMORY_H_
#include "semaphore.h"


typedef struct {
	//holds the value that the calculating process will use
	int calcValue;
	// mutex for calcValue
	semaphore_t calcMutex;

	// the stack for the producer/consumer processes
	int stack[10];
	semaphore_t stackMutex;

	// pointer to the top of the stack that the producer/consumer uses
	int topOfStack;
	semaphore_t tosMutex;
} sharedMemory_t;

int init_sharedMemory(sharedMemory_t *sm);
int init_value(sharedMemory_t *sm);

int init_tos(sharedMemory_t *sm);
int getValue(sharedMemory_t *sm);

int getTos(sharedMemory_t *sm);

int pushStack(sharedMemory_t *sm, int the_value);

int popStack(sharedMemory_t *sm);


#endif /* SHAREDMEMORY_H_ */
